//
//  SelectDateView.swift
//  KaMengApplication
//
//  Created by DUONIU_MAC on 2018/11/5.
//  Copyright © 2018年 DUONIU_MAC. All rights reserved.
//

import UIKit

class SelectDateView: UIView {
    
    let cancelBtn = UIButton()
    let confirmBtn = UIButton()
    let datePicker = UIDatePicker()

    init() {
        super.init(frame: .zero)
        
        let bgView = UIView()
        bgView.backgroundColor = UIColor.mineColor()
        self.addSubview(bgView)
        
        datePicker.backgroundColor = UIColor.white
        datePicker.datePickerMode = .date
        datePicker.locale = Locale.init(identifier: "zh_CN")
        bgView.addSubview(datePicker)
        
        cancelBtn.backgroundColor = UIColor.white
        cancelBtn.setTitle(global_cancel, for: .normal)
        cancelBtn.setTitleColor(UIColor.black, for: .normal)
        cancelBtn.titleLabel?.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        bgView.addSubview(cancelBtn)
        
        confirmBtn.backgroundColor = UIColor.white
        confirmBtn.setTitle(global_confirm, for: .normal)
        confirmBtn.setTitleColor(UIColor.black, for: .normal)
        confirmBtn.titleLabel?.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        bgView.addSubview(confirmBtn)
        
        bgView.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(RATIO(maxNum: 20))
            make.right.equalToSuperview().offset(RATIO(maxNum: -20))
            make.height.equalTo(RATIO_H(maxNum: 230))
        }
        
        datePicker.snp.makeConstraints { (make) in
           
            make.left.right.top.equalToSuperview()
            make.height.equalTo(RATIO_H(maxNum: 180))
        }
        
        cancelBtn.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.equalTo(datePicker.snp.bottom).offset(1)
            make.bottom.equalToSuperview()
            make.right.equalTo(datePicker.snp.centerX).offset(-0.5)
        }
        
        confirmBtn.snp.makeConstraints { (make) in
            make.left.equalTo(cancelBtn.snp.right).offset(1)
            make.top.equalTo(cancelBtn)
            make.bottom.equalTo(cancelBtn)
            make.right.equalToSuperview()
        }
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
